package com.srlg.liteflow.config;

import com.srlg.liteflow.ctx.CustomContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowFact;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
import lombok.extern.slf4j.Slf4j;

/**
 *
 */
@LiteflowComponent
@Slf4j
public class CmpConfig {

    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeType = NodeTypeEnum.COMMON, nodeId = "ma")
    public void processA(NodeComponent bindCmp, @LiteflowFact("name") String name,
                         @LiteflowFact("age") Integer age) {
        CustomContext cb = bindCmp.getContextBean(CustomContext.class);
        cb.setName("mm");
        cb.setAge(13);
        log.info("=========>  bindCmp:{}, name:{}, age:{}", bindCmp, name, age);
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeType = NodeTypeEnum.COMMON, nodeId = "mb")
    public void processB(NodeComponent bindCmp, @LiteflowFact("name") String name,
                         @LiteflowFact("cc.age") Integer age) {

        log.info("=========>  bindCmp:{}, name:{}, age:{}", bindCmp, name, age);
    }
}
